package edu.nyu.hps.assignment5;

public class Red extends Voronoi {

	
	public Red(int p, int s) {
		time=120;
		player = p;
		stones = s;
		diameter = (int) (Math.sqrt(2)*501/2);
		for (int i = 0; i < 501; i++) {
			for (int j = 0; j < 501; j++) {
				grid[i][j] = new Point(i, j);
			}
		}
		center = grid[250][250];
	}

	@Override
	public void updateArea() {
		myMyArea = 0;
		myOpponentArea = 0;
		for(int i=0;i<501;i++){
			for(int j=0;j<501;j++){
				if(grid[i][j].takenBy == 0)
					myMyArea+=1;
				else
					myOpponentArea+=1;
			}
		}
	}

	public Point strategy1(){
		myStones.add(grid[125][125]);
		grid[125][125].taken = true;
		grid[125][125].takenBy = player;
		return grid[125][125];
	}

	public Point strategy2(){
		Point opp = opponentStones.get(opponentStones.size()-1);
		int i=501-opp.x;
		int j=501-opp.y;
		while(true){
			if(!grid[i][j].taken){
				myStones.add(grid[i][j]);
				grid[i][j].taken = true;
				return grid[i][j];
			}
			i+=10;
			j+=10;
		}
	}
	public Point strategy3(){
		Moves m = new Moves();
		m.createSquare();
		return m.computeBestPoint();
	}

	@Override
	public Point throwAt() {
		double area,bestArea = 0;
		Point bestPoint = null;
		updatesBeforeComputing();
		if(myStones.size()==0){	
			return strategy1();
		}
		else 
			return strategy3();
	}
	
}
